package com.adee.nowcoder.huawei;

import java.util.*;

public class T019_HJ19 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>(100);
        Map<String, Integer> map = new HashMap<>();
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            if(str.trim().length() == 0) break;
            String[] arr = str.split(" ");
            String path = arr[0];
            String line = arr[1];
            String file = path.substring(path.lastIndexOf("\\")+1);
            if (file.length() > 16) file = file.substring(file.length()-16);
            String k = file + " " + line;
            if(map.containsKey(k)) {
                map.put(k, map.get(k) + 1);
            } else {
                map.put(k, 1);
                list.add(k);
            }
        }
        int beginIdx = list.size() > 8 ? (list.size()-8) : 0;
        for (int i = beginIdx; i < list.size(); i++) {
            String key = list.get(i);
            System.out.println(key + " " + map.get(key));
        }
    }
}
